//#include "tcp_select_server.h"
#include <stdio.h>      /* for printf(), fprintf() */
#include <winsock.h>    /* for socket(),... */
#include <stdlib.h>     /* for exit() */
//#include "gotoxy.h"
#include <windows.h>
#include <iostream>
#include <string>

using namespace std;

#define MAXPENDING 5    /* Maximum outstanding connection requests */
#define RCVBUFSIZE 156   /* Size of receive buffer */
//using namespace std;
//struct per_connection conn_list[MAX_CONNS];
//static int max_conns = 0;
#define IPLENGTH 16

#define WhereToPrintNetworkInfo	6

class TCPNetwork
{
private:
	//  Used For Server listen  Server Date sock  clint sock
    int listenSock,             servSock[10],     clintSock;		/* Socket descriptor for server */
    struct sockaddr_in echoServAddr;/* Local address */
    struct sockaddr_in echoClntAddr;/* Client address */

    struct sockaddr_in srvrAddr; /* Local address */
    struct sockaddr_in clntAddr; /* Client address */

    unsigned short echoServPort;	/* Server port */

	unsigned short servPort;     /* Server port */

    int clntLen;					/* Length of client address data structure */
    WSADATA wsaData;				/* Structure for WinSock setup communication */
	char echoBuffer[RCVBUFSIZE];	/* Buffer for echo string */
	char recvBuffer[RCVBUFSIZE];	/* Buffer for echo string */
	int recvMsgSize;				/* Size of received message */
	int retval;
	int max_conns;
	fd_set readfds, writefds;

	char input[514];
	char Ipinput[IPLENGTH];
	void serverRecvDate(int,char **);
	void serverSendDate(int,char **);
public:

	TCPNetwork();
	~TCPNetwork();

	void DieWithError(char *errorMessage);  /* Error handling function */
	void setUpNetworkServer();
	void setUpNetworkClint(char *);
	
	void clintSendDate(char **);
	void clintRecvDate(char **);
	void changePortIP();

	void serverRecvDate(char **);
	void serverSendDate(char **);


};



